package ace.cmp.data.spring.data.jdbc.querydsl.rsql.core.manager.impl;

import ace.cmp.id.generator.api.IdGenerator;
import ace.cmp.spring.data.jdbc.querydsl.core.QuerydslRelationHelper;
import ace.cmp.spring.data.jdbc.querydsl.core.repository.QuerydslJdbcBaseRepository;
import ace.cmp.spring.data.jdbc.querydsl.core.util.QuerydslAnnotationUtils;
import ace.cmp.spring.data.jdbc.querydsl.rsql.core.RsqlQuerydslParser;
import ace.cmp.spring.data.jdbc.querydsl.rsql.core.RsqlQuerydslVisitor;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;

/**
 * 默认实现.
 *
 * @author caspar
 */
@Slf4j
public class ManagerImpl<EntityT, IdT> extends AbstractManager<EntityT, IdT> {

  @Getter(AccessLevel.PROTECTED)
  private final Class<IdT> idClass;

  @Getter(AccessLevel.PROTECTED)
  private final Class<EntityT> entityClass;

  @Getter(value = AccessLevel.PROTECTED)
  private final QuerydslJdbcBaseRepository<EntityT, IdT> repository;

  @Getter(value = AccessLevel.PROTECTED)
  private final IdGenerator<IdT> idGenerator;

  @Getter(value = AccessLevel.PROTECTED)
  private final QuerydslRelationHelper querydslRelationHelper;

  @Getter(value = AccessLevel.PROTECTED)
  private final RsqlQuerydslParser querydslParser;

  @Getter(value = AccessLevel.PROTECTED)
  private final RsqlQuerydslVisitor querydslVisitor;

  @Getter(value = AccessLevel.PROTECTED)
  private final QuerydslAnnotationUtils querydslAnnotationUtils;

  @Getter(value = AccessLevel.PROTECTED)
  private final RelationalMappingContext relationalMappingContext;

  public ManagerImpl(
      Class<IdT> idClass,
      Class<EntityT> entityClass,
      QuerydslJdbcBaseRepository<EntityT, IdT> repository,
      IdGenerator<IdT> idGenerator,
      QuerydslRelationHelper querydslRelationHelper,
      RsqlQuerydslParser querydslParser,
      RsqlQuerydslVisitor querydslVisitor,
      QuerydslAnnotationUtils querydslAnnotationUtils,
      RelationalMappingContext relationalMappingContext) {
    this.idClass = idClass;
    this.entityClass = entityClass;
    this.repository = repository;
    this.idGenerator = idGenerator;
    this.querydslRelationHelper = querydslRelationHelper;
    this.querydslParser = querydslParser;
    this.querydslVisitor = querydslVisitor;
    this.querydslAnnotationUtils = querydslAnnotationUtils;
    this.relationalMappingContext = relationalMappingContext;
  }
}
